<?php
	class Mycontroller extends CI_Controller {
		
		function Mycontroller () {
			parent::__construct();
			
			$this->load->helper('url');
			$this->load->helper('form');
			//$this->load->scaffolding('article');
		}
		function index () {
			$data['title']='Mi titulo';
			$data['heading']='Mi heading';
			$this -> load -> view('seccionplanificacion_view',$data);
		}

		public function createObjects()
		{
		    // create a new user object
		    $user = new Entities\User;
		    $user->setFirstName('Joel');
		    $user->setLastName('Verhagen');
		    $user->setPassword(md5('Emma Watson'));
		    $user->setEmail('joel@joelverhagen.com');
		    $user->setWebsite('http://www.joelverhagen.com');
		    $user->setCreated(new DateTime());
		   
		    // standard way in CodeIgniter to access a library in a controller: $this->library_name->member->memberFunction()
		    // save the object to database, so that it can obtain its ID
		    $this->doctrine->em->persist($user);
		   
		    // create a new article object
		    $article = new Entities\Article;
		    $article->setTitle('Emma Watson is extremely talented, no?');
		    $article->setContent('By talented, I mean good at lookin\' good.');
		    $article->setCreated(new DateTime());
		    // the user object you pass must be persisted first!
		    $article->setUser($user);
		   
		    // save the article object to the database
		    $this->doctrine->em->persist($article);
		    $this->doctrine->em->flush();
		   
		    echo "<b>Success!</b>";
		}
	}
?>